<?php


namespace app\admin\model;


use think\Model;

class UserBonuslog extends Model
{
	//计算升级的总分润
	public function getUpgradeTotalMoney(){
		$total=0;
		$where=["blog_type"=>1,"blog_state"=>0];
		$query_date = input('query_date', '', 'trim,htmlspecialchars');
		if (!empty($query_date)) {
			$query_date = explode(" - ", $query_date);
			$query_date[0] = strtotime($query_date[0]);
			$query_date[1] = strtotime($query_date[1] . "+1day");
		}
		if(!empty($query_date)){
			$total = $this->whereBetween("blog_time",$query_date)->where($where)->sum("blog_money");
		}else{
			$total = $this->where($where)->sum("blog_money");
		}
		return $total;
	}


	//计算还款总分润
	public function caclPayTotalMoney(){
		$total = 0;
		$where=[];
		$where[]=["blog_type","=","3"];
		$query_date = input('query_date', '', 'trim,htmlspecialchars');
		if (!empty($query_date)) {
			$query_date = explode(" - ", $query_date);
			$query_date[0] = strtotime($query_date[0]);
			$query_date[1] = strtotime($query_date[1] . "+1day");
			$where[]=["blog_time","between",$query_date];
		}
		$total = $this->where($where)->sum("blog_money");
		return $total;
	}
}